package com.mashibing.listener;

import com.mashibing.config.RabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author zjw
 * @description
 */
@Component
public class BusinessListener {

    @RabbitListener(queues = {RabbitMQConfig.BUSINESS_QUEUE})
    public void consume(String msg, Channel channel, Message message) throws InterruptedException, IOException {
        // 通知商家成功！
        Thread.sleep(400);
        System.out.println("通知商家成功！！");
        // 手动ACK
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}
